package com.ssy.lingxi.member.merchant.controller.mobile;

import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.model.vo.PageVO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.member.merchant.model.vo.lifecycle.request.CommonIdVO;
import com.ssy.lingxi.member.merchant.model.vo.mobile.request.MobileMemberTradeCommentSaveVO;
import com.ssy.lingxi.member.merchant.model.vo.mobile.response.*;
import com.ssy.lingxi.member.merchant.service.base.IBaseMemberCacheService;
import com.ssy.lingxi.member.merchant.service.mobile.IMobileMemberCommentService;
import org.springframework.http.HttpHeaders;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @menu App - 评价中心
 * @author yzc
 * @version 2.0.0
 * @date 2021/9/3
 */
@RestController
@RequestMapping("/member/mobile/comment")
public class MobileMemberCommentController {
    @Resource
    private IMobileMemberCommentService mobileMemberCommentService;

    @Resource
    private IBaseMemberCacheService memberCacheService;

    /**
     * 评价中心 - 待评价 - 分页列表
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/wait/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileWaitCommentOrderProductPageVO>> pageWaitOrderComment(@RequestHeader HttpHeaders headers, @Validated PageVO pageVO) {
        UserLoginCacheDTO loginUser = memberCacheService.needLoginFromMobile(headers);
        return mobileMemberCommentService.pageWaitOrderComment(loginUser, pageVO);
    }

    /**
     * 评价中心 - 待评价 - 评价商品详情
     * @param headers Http头部信息
     * @param commonIdVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/order/product/get", method = RequestMethod.GET)
    public Wrapper<MobileCommentOrderProductVO> getMemberOrderComment(@RequestHeader HttpHeaders headers, @Valid CommonIdVO commonIdVO) {
        UserLoginCacheDTO loginUser = memberCacheService.needLoginFromMobile(headers);
        return mobileMemberCommentService.getMemberOrderComment(loginUser, commonIdVO);
    }

    /**
     * 评价中心 - 待评价 - 写评价
     * @param headers Http头部信息
     * @param memberTradeCommentSaveVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public Wrapper<Void> saveMemberComment(@RequestHeader HttpHeaders headers, @RequestBody @Valid MobileMemberTradeCommentSaveVO memberTradeCommentSaveVO) {
        UserLoginCacheDTO loginUser = memberCacheService.needLoginFromMobile(headers);
        return mobileMemberCommentService.saveMemberComment(loginUser, memberTradeCommentSaveVO);
    }

    /**
     * 评价中心 - 已评价 - 分页列表
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/complete/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileCompleteCommentPageVO>> pageCompleteOrderComment(@RequestHeader HttpHeaders headers, @Validated PageVO pageVO) {
        UserLoginCacheDTO loginUser = memberCacheService.needLoginFromMobile(headers);
        return mobileMemberCommentService.pageCompleteOrderComment(loginUser, pageVO);
    }

    /**
     * 评价中心 - 已评价 - 评价商品详情
     * @param headers Http头部信息
     * @param commonIdVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/product/comment/get", method = RequestMethod.GET)
    public Wrapper<MobileCommentHistoryVO> getMemberCommentHistory(@RequestHeader HttpHeaders headers, @Valid CommonIdVO commonIdVO) {
        UserLoginCacheDTO loginUser = memberCacheService.needLoginFromMobile(headers);
        return mobileMemberCommentService.getMemberCommentHistory(loginUser, commonIdVO);
    }

    /**
     * 评价中心 - 卖家对我的评价 - 分页列表
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/receive/page", method = RequestMethod.GET)
    public Wrapper<PageData<MobileReceiveCommentPageVO>> pageReceiveOrderComment(@RequestHeader HttpHeaders headers, @Validated PageVO pageVO) {
        UserLoginCacheDTO loginUser = memberCacheService.needLoginFromMobile(headers);
        return mobileMemberCommentService.pageReceiveOrderComment(loginUser, pageVO);
    }
}
